using System;
using System.Collections.Generic;
using System.Text;

namespace ca.metaobjects.csogateway
{
	/// <summary>
	/// An unexpected exception in the CSO Gateway. Unexpected exceptions are those not caused by usual mistakes from the user.
	/// </summary>
	public class CsoGatewayError : Exception
	{
        /// <summary>
		/// Initializes a new instance of the <see cref="CsoGatewayError"/> class.
        /// </summary>
		private CsoGatewayError()
			: base()
		{
		}

        /// <summary>
		/// Initializes a new instance of the <see cref="CsoGatewayError"/> class
        /// with a specified error message.
        /// </summary>
		/// <param name="eMessage">The error message that explains the reason for the error.</param>
		/// <param name="stringArgs">Array of string filling error message missing parts.</param>
		internal CsoGatewayError(ErrorMessage eMessage, params string[] stringArgs)
			: base("[" + eMessage.id + "] " + String.Format(eMessage.message, stringArgs))
		{
		}

        /// <summary>
		/// Initializes a new instance of the <see cref="CsoGatewayError"/> class
        /// with a specified error message and a reference to the inner exception that is the cause of this error.
        /// </summary>
		/// <param name="eMessage">The error message that explains the reason for the error.</param>
        /// <param name="innerException">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.</param>
		/// <param name="stringArgs">Array of string filling error message missing parts.</param>
		internal CsoGatewayError(ErrorMessage eMessage, Exception innerException, params string[] stringArgs)
			: base("[" + eMessage.id + "] " + String.Format(eMessage.message, innerException, stringArgs))
        {
        }
	}
}
